<?php

/**
 *  imitator
 */

include "./sTjise.php";
use Tjise\TjiseAPP;

function main_handler($event, $context) {
/********************************* 云函数 GET POST 转化 ************************************************************* */
    $_POST = null;
    $_GET = null;
    $event = json_decode(json_encode($event), true);
    $_GET = $event['queryString'];
    if($event['body']){
        $postbody = explode("&",$event['body']);
        foreach ($postbody as $postvalues) {
            $pos = strpos($postvalues,"=");
            $_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
        }
    }

    print_r("\n-----------------------------------------\n");
    print_r("操作审计\n");
    print_r("请求参数： ".$event['Message']."\n");
    print_r("时间： ".$event['Time']);
    print_r("\n-----------------------------------------\n");
    print_r("GET\n");
    print_r($_GET);
    print_r("\n-----------------------------------------\n");


    //返回参数
    $res = [
        'isBase64Encoded' => false,
        'statusCode' => 200,
        'headers' => ['Content-Type' => 'application/json'],
        'body' => ''
    ];
/******************************************************************************************************************* */  


    $Tjise = new TjiseAPP();
    $Tjise->login('手机号','密码');

    $res['body'] = json_encode([
        'Reply'=> $Tjise->request( $_GET['type'] ? $_GET['type'] : $event['Message'] )
    ]);
    return $res;




    return [
        'isBase64Encoded' => false,
        'statusCode' => 200,
        'headers' => ['Content-Type' => 'application/json'],
        'body' => json_encode(['Reply'=> "false"])
    ];

}
?>
